//
//  HeroNextCzNextTableViewController.m
//  LOLBOX
//
//  Created by lanou3g on 15/12/19.
//  Copyright © 2015年 张明. All rights reserved.
//

#import "HeroNextCzNextTableViewController.h"
#import "ListTableViewCell.h"
#import "LooserTableViewCell.h"
#import "UIImageView+WebCache.h"
static CGFloat kImageHeight = 170.f;
@interface HeroNextCzNextTableViewController ()
@property(nonatomic,strong)UIImageView *imageView;
@property(nonatomic,strong)UILabel *nameLable;
@property(nonatomic,strong)UILabel *typeLable;
@property(nonatomic,strong)UILabel *priceLable;
@property(nonatomic,assign)CGFloat height;

@end
@implementation HeroNextCzNextTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;//设置导航栏透明否
    self.tabBarController.tabBar.translucent = NO;
    self.tableView.backgroundColor = [UIColor whiteColor];
    //注册cell
    [self.tableView registerNib:[UINib nibWithNibName:@"ListTableViewCell" bundle:nil] forCellReuseIdentifier:@"nextCellOne"];
    [self.tableView registerClass:[LooserTableViewCell class] forCellReuseIdentifier:@"nextCellTwo"];
    //添加皮肤图片
    self.imageView = [[UIImageView alloc]init];
    self.imageView.frame = CGRectMake(0,-kImageHeight , self.tableView.frame.size.width, kImageHeight);
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:self.imageUrl]];
    self.nameLable.text = self.name;
    self.priceLable.text = self.price;
    self.typeLable.text = self.type;
    [self.view addSubview:self.imageView];
    [self createImageViewChild];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;//隐藏分割线
}
//往皮肤上创建label
-(void)createImageViewChild{
    self.nameLable = [[UILabel alloc] init];
    self.nameLable.frame = CGRectMake(10, self.imageView.frame.size.height -80, self.view.frame.size.width-20, 20);
    self.nameLable.font = [UIFont systemFontOfSize:14];
    self.nameLable.textColor = [UIColor whiteColor];
    [self.imageView addSubview:self.nameLable];
    self.typeLable = [[UILabel alloc] init];
    self.typeLable.frame = CGRectMake(10, self.imageView.frame.size.height -60, self.view.frame.size.width - 20, 20);
    self.typeLable.font = [UIFont systemFontOfSize:14];
    self.typeLable.textColor = [UIColor whiteColor];
    [self.imageView addSubview:self.typeLable];
    self.priceLable = [[UILabel alloc] init];
    self.priceLable.frame = CGRectMake(10, self.imageView.frame.size.height -40, self.view.frame.size.width - 20, 20);
    self.priceLable.font = [UIFont systemFontOfSize:14];
    self.priceLable.textColor = [UIColor whiteColor];
    [self.imageView addSubview:self.priceLable];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        ListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"nextCellOne" forIndexPath:indexPath];
        cell.titleLable.text = @"技能加点";
        NSArray *array = [self.model.skill componentsSeparatedByString:@","];
        [self getImageWithUrl:cell.imv1 andWith:array[0]];
        [self getImageWithUrl:cell.imv2 andWith:array[1]];
        [self getImageWithUrl:cell.imv3 andWith:array[2]];
        [self getImageWithUrl:cell.imv4 andWith:array[3]];
        [self getImageWithUrl:cell.imv5 andWith:array[4]];
        [self getImageWithUrl:cell.imv6 andWith:array[5]];
        [self getImageWithUrl:cell.imv7 andWith:array[6]];
        [self getImageWithUrl:cell.imv8 andWith:array[7]];
        [self getImageWithUrl:cell.imv9 andWith:array[8]];
        [self getImageWithUrl:cell.imv10 andWith:array[9]];
        [self getImageWithUrl:cell.imv11 andWith:array[10]];
        [self getImageWithUrl:cell.imv12 andWith:array[11]];
        [self getImageWithUrl:cell.imv13 andWith:array[12]];
        [self getImageWithUrl:cell.imv14 andWith:array[13]];
        [self getImageWithUrl:cell.imv15 andWith:array[14]];
        [self getImageWithUrl:cell.imv16 andWith:array[15]];
        [self getImageWithUrl:cell.imv17 andWith:array[16]];
        [self getImageWithUrl:cell.imv18 andWith:array[17]];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    LooserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"nextCellTwo" forIndexPath:indexPath];
    cell.detailTextLabel.numberOfLines = 0;
    if (indexPath.row == 1) {
        cell.titleLable.text = @"前期出装";
        NSArray *array1 = [self.model.pre_cz componentsSeparatedByString:@","];
        if (array1.count >= 1) {
            [cell.imv1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[0]]]];
        }
        if (array1.count >=2) {
            [cell.imv2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[1]]]];
        }
        if (array1.count >=3) {
            [cell.imv3 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[2]]]];
        }
        if (array1.count >= 4) {
            [cell.imv4 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[3]]]];
        }if (array1.count >=5) {
            [cell.imv5 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[4]]]];
        }if (array1.count >= 6) {
            [cell.imv6 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[5]]]];
        }
        if ([self.model.pre_explain isEqualToString:@""]) {
            self.model.pre_explain = @"...";
        }
        
        cell.describeLable.text = self.model.pre_explain;
        
        self.height = [cell getHeightWithString:self.model.pre_explain];
        
    }
    if (indexPath.row == 2) {
        cell.titleLable.text = @"中期出装";
        NSArray *array1 = [self.model.mid_cz componentsSeparatedByString:@","];
        if (array1.count >= 1) {
            [cell.imv1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[0]]]];
        }
        if (array1.count >=2) {
            [cell.imv2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[1]]]];
        }
        if (array1.count >=3) {
            [cell.imv3 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[2]]]];
        }
        if (array1.count >= 4) {
            [cell.imv4 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[3]]]];
        }if (array1.count >=5) {
            [cell.imv5 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[4]]]];
        }if (array1.count >= 6) {
            [cell.imv6 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[5]]]];
        }
        if ([self.model.mid_explain isEqualToString:@""]) {
            self.model.mid_explain = @"...";
        }
        
        cell.describeLable.text = self.model.mid_explain;
        self.height = [cell getHeightWithString:self.model.mid_explain];
        
    }
    if (indexPath.row == 3) {
        cell.titleLable.text = @"后期出装";
        NSArray *array1 = [self.model.end_cz componentsSeparatedByString:@","];
        if (array1.count >= 1) {
            [cell.imv1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[0]]]];
        }
        if (array1.count >=2) {
            [cell.imv2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[1]]]];
        }
        if (array1.count >=3) {
            [cell.imv3 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[2]]]];
        }
        if (array1.count >= 4) {
            [cell.imv4 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[3]]]];
        }if (array1.count >=5) {
            [cell.imv5 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[4]]]];
        }if (array1.count >= 6) {
            [cell.imv6 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[5]]]];
        }
        if ([self.model.end_explain isEqualToString:@""]) {
            self.model.end_explain = @"...";
        }
        
        cell.describeLable.text = self.model.end_explain;
        self.height = [cell getHeightWithString:self.model.end_explain];
        
    }
    if (indexPath.row == 4) {
        cell.titleLable.text = @"逆风出装";
        NSArray *array1 = [self.model.nf_cz componentsSeparatedByString:@","];
        if (array1.count >= 1) {
            [cell.imv1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[0]]]];
        }
        if (array1.count >=2) {
            [cell.imv2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[1]]]];
        }
        if (array1.count >=3) {
            [cell.imv3 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[2]]]];
        }
        if (array1.count >= 4) {
            [cell.imv4 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[3]]]];
        }if (array1.count >=5) {
            [cell.imv5 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[4]]]];
        }if (array1.count >= 6) {
            [cell.imv6 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/zb/%@_64x64.png",array1[5]]]];
        }
        if ([self.model.nf_explain isEqualToString:@""]) {
            self.model.nf_explain = @"...";
        }
        cell.describeLable.text = self.model.nf_explain;
        self.height = [cell getHeightWithString:self.model.nf_explain];
    }
    return cell;
}
//cell之间的间距设置
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return  150;
    }
    if (self.height < 80) {
        return 100;
    }
    return self.height;
}

//技能加点上添加技能图片
-(void)getImageWithUrl:(UIImageView *)myView andWith:(NSString *)urlString{
    [myView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://img.lolbox.duowan.com/abilities/%@_%@_64x64.png?v=10&OSType=iOS7.0.3",self.aString,urlString]]];
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
